<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = []
      for (let i = 0; i < 5; i++) {
        let sum = +prompt(`请输入第${i + 1}个年龄`)
        if (i >= 0 && i <= 100) {
          arr.push(sum)
        }
      }
      document.write(`所有人的年龄为：${arr}岁<br>`);

      for (let i = 0; i < arr.length; i++) {
        if (arr[i] >= 18) {
          document.write(`${arr[i]}岁已成年<br>`)
        }
      }

      let all = 0
      for (let i = 0; i < arr.length; i++) {
        all += arr[i]
      }
      document.write(`所有人年龄总和：${all}<br>`)

      let average = 0
      for (let i = 0; i < arr.length; i++) {
        average = all / arr[i]
      }
      document.write(`平均年龄为:${average}<br>`)

      let max = arr[0]
      let minimax = arr[0]
      for (let i = 1; i < arr.length; i++) {
        if (max < arr[i]) {
          max = arr[i]
        } else if (minimax > arr[i]) {
          minimax = arr[i]
        }
      }
      document.write(`最大年龄:${max}<br>`)
      document.write(`最小年龄:${minimax}<br>`)
    </script>
  </body>
</html>
